package com.cmyshare.design.strategyAndFactory;

/**
 * @Author cmy
 * @Date 2025/10/13 14:20
 * @version 1.0
 * @desc 支付工厂类
 */
// 支付工厂类
public class PaymentFactory {
    // 根据支付类型获取对应的支付策略
    public static PaymentStrategy getPaymentStrategy(String paymentType) {
        switch (paymentType.toLowerCase()) {
            case "alipay":
                return new AlipayStrategy();
            case "wechat":
                return new WechatPayStrategy();
            case "unionpay":
                return new UnionPayStrategy();
            default:
                throw new IllegalArgumentException("不支持的支付方式: " + paymentType);
        }
    }
}

